﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:nc="http://schemas.ncore.com/wpf/xaml/colorbox"  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <!--
    
    Please note:
    
    The style refers to internal types of the ColorBox.dll. These types are not accessable outside of the Libary.
    Therefore you have to embed this style into the dll or declare the internal types public in order to be able to apply this style.
    
    The style definitions are forked and modified from the Generic.xaml
    
    -->
    
    <Geometry x:Key="SkewIcon">M456.021,227.816L545.590,227.816L456.021,362.171L366.452,362.171L456.021,227.816</Geometry>
    <Geometry x:Key="TranslateIcon">M384,289.828L384,363L457.171,363M384,363L457.171,289.828M480,267L480,310.011L435.711,267L480,267</Geometry>
    <Geometry x:Key="RotateIcon">F1 M 32.0034,13.0019L 35.0033,16.002L 35.0034,24.0019L 27.0033,24.002L 24.0034,21.0019L 29.5944,21.0014C 28.2209,19.4668 26.2249,18.501 24.0033,18.501C 19.8606,18.501 16.5022,21.8593 16.5022,26.002C 16.5022,28.0734 17.3418,29.9486 18.6992,31.3061L 16.2241,33.7812C 14.2332,31.7903 13.0018,29.0399 13.0018,26.0019C 13.0018,19.926 17.9274,15.0004 24.0033,15.0004C 27.1557,15.0004 29.9984,16.3263 32.0042,18.4508L 32.0034,13.0019 Z</Geometry>
    <Geometry x:Key="ScaleIcon">F1 M 28,13L 36,13L 36,21L 33,24L 33,18.5L 24,27.5L 21.5,25L 30.5,16L 25,16L 28,13 Z M 13,18L 26,18L 23,21L 16,21L 16,33L 28,33L 28,26L 31,23L 31,36L 13,36L 13,18 Z</Geometry>
    <Geometry x:Key="CenterIcon">M502.672,272.601C502.672,298.366 481.785,319.252 456.021,319.252 430.257,319.252 409.370,298.366 409.370,272.601 409.370,246.837 430.257,225.950 456.021,225.950 481.785,225.950 502.672,246.837 502.672,272.601zM502.672,272.601C502.672,298.366 481.785,319.252 456.021,319.252 430.257,319.252 409.370,298.366 409.370,272.601 409.370,246.837 430.257,225.950 456.021,225.950 481.785,225.950 502.672,246.837 502.672,272.601zM470.531,272.601C470.531,280.615 464.035,287.111 456.021,287.111 448.007,287.111 441.511,280.615 441.511,272.601 441.511,264.588 448.007,258.091 456.021,258.091 464.035,258.091 470.531,264.588 470.531,272.601z</Geometry>
    <Geometry x:Key="FlipIcon">M384,267L384,363L480,363M384,363L459.026,286.973L438,267L479.000,267L479.000,307.000L459.026,286.973</Geometry>

    <Style TargetType="Path" x:Key="IconStyle">
        <Setter Property="Height" Value="16" />
        <Setter Property="Width" Value="16" />
        <Setter Property="Fill" Value="{DynamicResource GlyphBrush}" />
        <Setter Property="Stretch" Value="Fill" />
    </Style>

    <Style TargetType="Slider" x:Key="OpacitySliderStyle" BasedOn="{StaticResource {x:Type Slider}}">
        <Setter Property="Value" Value="{Binding Brush.Opacity, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" />
        <Setter Property="IsMoveToPointEnabled" Value="True" />
        <Setter Property="Margin" Value="2" />
        <Setter Property="Minimum" Value="0" />
        <Setter Property="Maximum" Value="1" />
    </Style>

    <BooleanToVisibilityConverter x:Key="BoolToVis"></BooleanToVisibilityConverter>
    <VisualBrush x:Key="AlphaBrush" Stretch="None" TileMode="Tile" ViewportUnits="Absolute" Viewport="0,0,8,8">
        <VisualBrush.Visual>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="4" />
                    <ColumnDefinition Width="4" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="4" />
                    <RowDefinition Height="4" />
                </Grid.RowDefinitions>
                <Rectangle Fill="#FFF" Grid.Row="0" Grid.Column="0" />
                <Rectangle Fill="#AAA" Grid.Row="0" Grid.Column="1" />
                <Rectangle Fill="#AAA" Grid.Row="1" Grid.Column="0" />
                <Rectangle Fill="#FFF" Grid.Row="1" Grid.Column="1" />
            </Grid>
        </VisualBrush.Visual>
    </VisualBrush>

    <!-- Gradient Stop Thumb Style -->
    <Style x:Key="SliderThumbStyle" TargetType="Thumb">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Thumb">
                    <Grid>
                        <Path Data="M0,3 L5,3 L7,0 L9,3 L14,3 L14,16 L0,16 Z" Height="16" Width="14"  Fill="{DynamicResource BaseBorderBrush}"  />

                        <Path Data="M1,4 L5,4 L7,1 L9,4 L13,4 L13,15 L1,15 Z" Height="16" Width="14" Fill="{TemplateBinding Background}" />
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Gradient Stop Slider Style -->
    <Style x:Key="GradientStopSliderStyle" TargetType="Slider">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Slider">
                    <Track x:Name="PART_Track">
                        <Track.Thumb>
                            <Thumb Style="{StaticResource SliderThumbStyle}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" />
                        </Track.Thumb>
                    </Track>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- ******* DoubleUpDown ******* -->
    <Style x:Key="NumericUpDown" TargetType="{x:Type nc:UpDownBase}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
        <Setter Property="Background" Value="{DynamicResource DarkerBaseBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource BaseBorderBrush}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Margin" Value="2" />
        <Setter Property="Padding" Value="5,1" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="nc:UpDownBase">
                    <nc:Spinner IsTabStop="False" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}">

                        <TextBox x:Name="PART_TextBox" BorderThickness="{TemplateBinding BorderThickness}" FocusVisualStyle="{x:Null}" Background="{TemplateBinding Background}" ContextMenu="{TemplateBinding ContextMenu}" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" MinWidth="20" AcceptsReturn="False" Padding="{TemplateBinding Padding}" TabIndex="{TemplateBinding TabIndex}" nc:TextBoxBehavior.SelectAllTextOnFocus="True" />

                    </nc:Spinner>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type nc:DoubleUpDown}" BasedOn="{StaticResource NumericUpDown}">
        <Setter Property="Increment" Value=".1" />
        <Setter Property="FormatString" Value="F1" />
    </Style>
    <!-- ******* Spinner ******* -->

    <Style TargetType="{x:Type nc:Spinner}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Background" Value="{DynamicResource DarkerBaseBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Focusable" Value="False" />
        <Setter Property="IsTabStop" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type nc:Spinner}">
                    <Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
                        <ContentPresenter />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <!-- ******* ColorBox ******* -->
    <Style TargetType="{x:Type nc:ColorBox}">
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="BorderThickness" Value="{DynamicResource DefaultBorderThickness}" />
        <Setter Property="Background" Value="{DynamicResource DarkerBaseBrush}" />
        <Setter Property="BorderBrush" Value="{DynamicResource PopupBorderBrush}" />
        <Setter Property="VerticalAlignment" Value="Top" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type nc:ColorBox}">
                    <Border x:Name="PART_Root" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{DynamicResource DefaultCornerRadius}">
                        <Border.InputBindings>
                            <KeyBinding Key="Del" Command="{x:Static nc:ColorBox.RemoveGradientStop}" />
                        </Border.InputBindings>

                        <Grid>
                            <ToggleButton x:Name="PART_OpenPopup" BorderThickness="0" MinHeight="20" Padding="1" Foreground="{TemplateBinding Foreground}" Background="{TemplateBinding Brush}">
                                <ToggleButton.Style>
                                    <Style TargetType="{x:Type ToggleButton}">
                                        <Setter Property="Template">
                                            <Setter.Value>
                                                <ControlTemplate TargetType="{x:Type ToggleButton}">
                                                    <DockPanel Background="Transparent" Margin="{TemplateBinding Padding}">
                                                        <Border MinWidth="20" Background="{StaticResource AlphaBrush}">
                                                            <Border Background="{TemplateBinding Background}" />
                                                        </Border>
                                                    </DockPanel>
                                                </ControlTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </ToggleButton.Style>
                            </ToggleButton>

                            <Popup IsOpen="{Binding ElementName=PART_OpenPopup,Path=IsChecked}" StaysOpen="False" AllowsTransparency="True" Width="{Binding ActualWidth, ElementName=PART_Root}" MinWidth="250" HorizontalOffset="-1">                                
                                <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Margin="10,0,10,10" CornerRadius="{DynamicResource DefaultCornerRadius}">
                                    <Border.Effect>
                                        <DropShadowEffect BlurRadius="10" ShadowDepth="0" Color="{DynamicResource Base6Color}" />
                                    </Border.Effect>
                                    <StackPanel Margin="5">

                                        <StackPanel.Resources>
                                            <Style x:Key="TBStyle" TargetType="TextBlock">
                                                <Setter Property="Margin" Value="2" />
                                                <Setter Property="VerticalAlignment" Value="Center" />
                                            </Style>
                                        </StackPanel.Resources>

                                        <!-- Available brush types -->
                                        <ListBox x:Name="listAvailableBrushType" HorizontalContentAlignment="Center" SelectedItem="{Binding BrushType, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}" ItemsSource="{Binding AvailableBrushTypes, RelativeSource={RelativeSource TemplatedParent}}">
                                            <ListBox.ItemsPanel>
                                                <ItemsPanelTemplate>
                                                    <UniformGrid Rows="1" Columns="4" />
                                                </ItemsPanelTemplate>
                                            </ListBox.ItemsPanel>
                                            <ListBox.ItemContainerStyle>
                                                <Style TargetType="ListBoxItem">
                                                    <Setter Property="Template">
                                                        <Setter.Value>
                                                            <ControlTemplate TargetType="ListBoxItem">
                                                                <Border x:Name="Border" Background="Transparent" Padding="0,3">
                                                                    <Path x:Name="Icon" Height="12" Width="20" Stretch="Fill" Fill="#FF403C3C" StrokeThickness="1" Stroke="Black" Data="M371,190L557,190 557,293 371,293 371,190z" />
                                                                </Border>

                                                                <ControlTemplate.Triggers>
                                                                    <Trigger Property="IsMouseOver" Value="True">
                                                                        <Setter Property="Background" Value="Gray" TargetName="Border" />
                                                                        <Setter Property="Foreground" Value="White" />
                                                                    </Trigger>
                                                                    <Trigger Property="IsSelected" Value="True">
                                                                        <Setter Property="Background" Value="Gray" TargetName="Border" />
                                                                        <Setter Property="Foreground" Value="White" />
                                                                    </Trigger>

                                                                    <DataTrigger Binding="{Binding}" Value="None">
                                                                        <Setter Property="ToolTip" Value="No Brush" />
                                                                        <Setter Property="StrokeThickness" TargetName="Icon" Value="0" />
                                                                        <Setter TargetName="Icon" Property="Data">
                                                                            <Setter.Value>
                                                                                <Geometry>M612,189L452.949,189L452.949,266.024L612,189 M612,196.999L452.949,273.999L612,273.999L612,196.999</Geometry>
                                                                            </Setter.Value>
                                                                        </Setter>
                                                                    </DataTrigger>
                                                                    <DataTrigger Binding="{Binding}" Value="Solid">
                                                                        <Setter Property="ToolTip" Value="Solid Color Brush" />
                                                                        <Setter Property="Fill" TargetName="Icon" Value="#FF403C3C" />
                                                                    </DataTrigger>
                                                                    <DataTrigger Binding="{Binding}" Value="Linear">
                                                                        <Setter Property="ToolTip" Value="Linear Gradient Brush" />
                                                                        <Setter Property="Fill" TargetName="Icon">
                                                                            <Setter.Value>
                                                                                <LinearGradientBrush StartPoint="0,.5" EndPoint="1,.5">
                                                                                    <GradientStop Color="#FF403C3C" Offset="0"></GradientStop>
                                                                                    <GradientStop Color="White" Offset="1"></GradientStop>
                                                                                </LinearGradientBrush>
                                                                            </Setter.Value>
                                                                        </Setter>
                                                                    </DataTrigger>
                                                                    <DataTrigger Binding="{Binding}" Value="Radial">
                                                                        <Setter Property="ToolTip" Value="Radial Gradient Brush" />
                                                                        <Setter Property="Fill" TargetName="Icon">
                                                                            <Setter.Value>
                                                                                <RadialGradientBrush>
                                                                                    <GradientStop Color="#FF403C3C" Offset="1" />
                                                                                    <GradientStop Color="White" />
                                                                                </RadialGradientBrush>
                                                                            </Setter.Value>
                                                                        </Setter>
                                                                    </DataTrigger>
                                                                </ControlTemplate.Triggers>
                                                            </ControlTemplate>
                                                        </Setter.Value>
                                                    </Setter>
                                                </Style>
                                            </ListBox.ItemContainerStyle>

                                        </ListBox>

                                        <!-- Color selector -->
                                        <ScrollViewer Margin="0,5,0,0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Disabled">
                                            <ScrollViewer.Style>
                                                <Style TargetType="ScrollViewer">
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}" Value="None">
                                                            <Setter Property="Visibility" Value="Collapsed" />
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </ScrollViewer.Style>

                                            <Grid>
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="*" />
                                                    <ColumnDefinition Width="5" />
                                                    <ColumnDefinition Width="20" />
                                                    <ColumnDefinition Width="5" />
                                                    <ColumnDefinition Width="20" />
                                                </Grid.ColumnDefinitions>

                                                <!-- saturation / brightness selector -->
                                                <Grid Grid.Column="0" ClipToBounds="true">
                                                    <nc:SaturationBrightnessSelector x:Name="SV" MinHeight="128" Saturation="{Binding Path=Saturation,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" Brightness="{Binding Path=Brightness,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" Hue="{Binding ElementName=H,Path=Hue}" />

                                                    <Grid VerticalAlignment="Top" HorizontalAlignment="Left" Margin="-6,-6,0,0" Width="12" Height="12">
                                                        <Ellipse Stroke="Black" />
                                                        <Ellipse Stroke="White" Margin="1" />
                                                        <Grid.RenderTransform>
                                                            <TranslateTransform X="{Binding ElementName=SV,Path=SaturationOffset}" Y="{Binding ElementName=SV,Path=BrightnessOffset}" />
                                                        </Grid.RenderTransform>
                                                    </Grid>
                                                </Grid>

                                                <!-- hue selector -->
                                                <nc:HueSelector x:Name="H" Grid.Column="2" Hue="{Binding Path=Hue,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" />
                                                <Path Grid.Column="2" HorizontalAlignment="Left" Margin="0,-5,0,5" Stroke="White" Fill="Black" Data="M 0 0 L 7 5 L 0 10Z">
                                                    <Path.RenderTransform>
                                                        <TranslateTransform Y="{Binding ElementName=H,Path=HueOffset}" />
                                                    </Path.RenderTransform>
                                                </Path>
                                                <Path Grid.Column="2" HorizontalAlignment="Right" Margin="0,-5,0,5" Stroke="White" Fill="Black" Data="M 0 5 L 7 0 L 7 10 Z">
                                                    <Path.RenderTransform>
                                                        <TranslateTransform Y="{Binding ElementName=H,Path=HueOffset}" />
                                                    </Path.RenderTransform>
                                                </Path>

                                                <!-- alpha selector -->
                                                <Rectangle Grid.Column="4" Fill="{StaticResource AlphaBrush}" />
                                                <nc:AlphaSelector x:Name="A" Grid.Column="4" Alpha="{Binding Path=Alpha,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" />
                                                <Path Grid.Column="4" HorizontalAlignment="Left" Margin="0,-5,0,5" Stroke="White" Fill="Black" Data="M 0 0 L 7 5 L 0 10Z">
                                                    <Path.RenderTransform>
                                                        <TranslateTransform Y="{Binding ElementName=A,Path=AlphaOffset}" />
                                                    </Path.RenderTransform>
                                                </Path>
                                                <Path Grid.Column="4" HorizontalAlignment="Right" Margin="0,-5,0,5" Stroke="White" Fill="Black" Data="M 0 5 L 7 0 L 7 10 Z">
                                                    <Path.RenderTransform>
                                                        <TranslateTransform Y="{Binding ElementName=A,Path=AlphaOffset}" />
                                                    </Path.RenderTransform>
                                                </Path>
                                            </Grid>
                                        </ScrollViewer>

                                        <!-- Current color viewer -->
                                        <Grid Margin="0,5,0,0" Height="20">

                                            <!-- Hide when brush type is None -->
                                            <Grid.Style>
                                                <Style TargetType="Grid">
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}" Value="None">
                                                            <Setter Property="Visibility" Value="Collapsed" />
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </Grid.Style>

                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="*" />
                                                <ColumnDefinition Width="5" />
                                                <ColumnDefinition Width="Auto" />
                                            </Grid.ColumnDefinitions>

                                            <Rectangle>
                                                <Rectangle.Fill>
                                                    <SolidColorBrush Color="{Binding Color, RelativeSource={RelativeSource TemplatedParent}}" />
                                                </Rectangle.Fill>
                                            </Rectangle>

                                            <TextBox x:Name="PART_CurrentColor" Text="{Binding Color, RelativeSource={RelativeSource TemplatedParent}}" nc:TextBoxBehavior.SelectAllTextOnFocus="True" Grid.Column="2" MinWidth="100">
                                                <TextBox.Style>
                                                    <Style TargetType="TextBox">
                                                        <Setter Property="Foreground" Value="{DynamicResource TextBrush}" />
                                                        <Setter Property="SelectionBrush" Value="{DynamicResource SelectedBrush}" />
                                                        <Setter Property="Template">
                                                            <Setter.Value>
                                                                <ControlTemplate TargetType="TextBox">
                                                                    <Border BorderBrush="{DynamicResource BaseBorderBrush}" BorderThickness="1" Padding="0">
                                                                        <ScrollViewer x:Name="PART_ContentHost" Margin="0" />
                                                                    </Border>
                                                                </ControlTemplate>
                                                            </Setter.Value>
                                                        </Setter>
                                                    </Style>
                                                </TextBox.Style>
                                            </TextBox>

                                        </Grid>

                                        <!-- Gradient Stop editor -->
                                        <Grid Margin="0,5,0,0" Focusable="False">

                                            <Grid.Style>
                                                <Style TargetType="Grid">
                                                    <Setter Property="Visibility" Value="Collapsed" />
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}" Value="Linear">
                                                            <Setter Property="Visibility" Value="Visible" />
                                                        </DataTrigger>
                                                        <DataTrigger Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}" Value="Radial">
                                                            <Setter Property="Visibility" Value="Visible" />
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </Grid.Style>

                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition />
                                                <ColumnDefinition Width="5" />
                                                <ColumnDefinition Width="Auto" MinWidth="45" />
                                            </Grid.ColumnDefinitions>

                                            <StackPanel Grid.Column="0" Focusable="False">

                                                <!-- Click to add gradient stop -->
                                                <nc:GradientStopAdder Height="20" Margin="7,0" Focusable="False" IsTabStop="False" FocusVisualStyle="{x:Null}" ColorBox="{Binding RelativeSource={RelativeSource TemplatedParent}}">
                                                    <nc:GradientStopAdder.Background>
                                                        <LinearGradientBrush GradientStops="{Binding Brush.GradientStops, RelativeSource={RelativeSource TemplatedParent}}" StartPoint="0, .5" EndPoint="1, .5" />
                                                    </nc:GradientStopAdder.Background>
                                                    <Button.Style>
                                                        <Style TargetType="Button">
                                                            <Setter Property="Template">
                                                                <Setter.Value>
                                                                    <ControlTemplate TargetType="Button">
                                                                        <Border BorderThickness="0" Background="{TemplateBinding Background}" />
                                                                    </ControlTemplate>
                                                                </Setter.Value>
                                                            </Setter>
                                                        </Style>
                                                    </Button.Style>
                                                </nc:GradientStopAdder>

                                                <!-- gradient stops -->
                                                <ListBox x:Name="lbGradientStops" ItemsSource="{Binding Path=Gradients, RelativeSource={RelativeSource TemplatedParent}}" SelectedItem="{Binding SelectedGradient,RelativeSource={RelativeSource TemplatedParent}}" Background="{x:Null}" Style="{x:Null}" BorderThickness="0" FocusVisualStyle="{x:Null}" Focusable="False" IsTabStop="False">
                                                    <ListBox.ItemContainerStyle>
                                                        <Style TargetType="ListBoxItem">
                                                            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
                                                            <Setter Property="IsTabStop" Value="False" />
                                                            <Setter Property="Template">
                                                                <Setter.Value>
                                                                    <ControlTemplate TargetType="ListBoxItem">
                                                                        <nc:GradientStopSlider x:Name="PART_Slider" BorderBrush="Black" IsTabStop="False" Style="{StaticResource GradientStopSliderStyle}" Value="{Binding Offset}" Minimum="0" Maximum="1" ColorBox="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type nc:ColorBox}}}" SelectedGradient="{Binding}" Margin="0,0,0,2">
                                                                            <nc:GradientStopSlider.Background>
                                                                                <SolidColorBrush Color="{Binding Color}" />
                                                                            </nc:GradientStopSlider.Background>
                                                                        </nc:GradientStopSlider>

                                                                        <ControlTemplate.Triggers>
                                                                            <Trigger Property="IsMouseOver" Value="True">
                                                                                <Setter Property="BorderBrush" TargetName="PART_Slider" Value="Orange" />
                                                                            </Trigger>
                                                                            <Trigger Property="IsSelected" Value="True">
                                                                                <Setter Property="BorderBrush" TargetName="PART_Slider" Value="Blue" />
                                                                                <Setter Property="Effect" TargetName="PART_Slider">
                                                                                    <Setter.Value>
                                                                                        <DropShadowEffect ShadowDepth="2" BlurRadius="2" Direction="270" />
                                                                                    </Setter.Value>
                                                                                </Setter>
                                                                            </Trigger>
                                                                        </ControlTemplate.Triggers>
                                                                    </ControlTemplate>
                                                                </Setter.Value>
                                                            </Setter>
                                                        </Style>
                                                    </ListBox.ItemContainerStyle>

                                                    <ListBox.ItemsPanel>
                                                        <ItemsPanelTemplate>
                                                            <Grid IsItemsHost="True" />
                                                        </ItemsPanelTemplate>
                                                    </ListBox.ItemsPanel>

                                                </ListBox>

                                            </StackPanel>

                                            <Button Grid.Column="2" Command="{x:Static nc:ColorBox.ReverseGradientStop}" Background="Transparent" ToolTip="Reverse gradient stops">
                                                <Button.Style>
                                                    <Style TargetType="Button">
                                                        <Setter Property="Template">
                                                            <Setter.Value>
                                                                <ControlTemplate TargetType="Button">
                                                                    <Border Name="Border"  Background="{TemplateBinding Background}">
                                                                        <Path x:Name="Icon" Data="F1 M 10.0001,27L 10,16L 29.25,16L 25,12L 31.5,12L 38,18L 31.5,24L 25,24L 29.25,20L 14,20L 14,23.5L 10.0001,27 Z M 38,21L 38,32L 18.75,32L 23,36L 16.5,36L 10,30L 16.5,24L 23,24L 18.75,28L 34,28L 34,24.5L 38,21 Z" StrokeThickness="0" Fill="{DynamicResource GlyphBrush}" Height="16" Width="20" Stretch="Fill" />
                                                                    </Border>
                                                                    <ControlTemplate.Triggers>
                                                                        <Trigger Property="IsMouseOver" Value="True">
                                                                            <Setter TargetName="Icon" Property="Fill" Value="{DynamicResource SelectedBrush}" />
                                                                        </Trigger>
                                                                        <Trigger Property="IsPressed" Value="True">
                                                                            <Setter Property="Fill" TargetName="Icon" Value="{DynamicResource DarkerSelectedBrush}" />   
                                                                        </Trigger>
                                                                    </ControlTemplate.Triggers>
                                                                </ControlTemplate>
                                                            </Setter.Value>
                                                        </Setter>
                                                    </Style>
                                                </Button.Style>
                                            </Button>

                                        </Grid>

                                        <!-- Additional Properties -->
                                        <StackPanel Margin="0,5,0,0">
                                            <StackPanel.Style>
                                                <Style TargetType="StackPanel">
                                                    <Style.Triggers>
                                                        <DataTrigger Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}" Value="None">
                                                            <Setter Property="Visibility" Value="Collapsed" />
                                                        </DataTrigger>
                                                    </Style.Triggers>
                                                </Style>
                                            </StackPanel.Style>

                                            <ToggleButton x:Name="PART_AdditionalPropertyOpen" BorderBrush="{TemplateBinding BorderBrush}" ToolTip="Additional Properties" Height="20">
                                                <ToggleButton.Style>
                                                    <Style TargetType="ToggleButton">
                                                        <Setter Property="Template">
                                                            <Setter.Value>
                                                                <ControlTemplate TargetType="ToggleButton">
                                                                    <Border x:Name="Border" Background="Transparent" >
                                                                        <Path x:Name="Icon" Data="M 0,0 L9,12 L18,0 Z" Height="4" Width="7" Fill="{DynamicResource GlyphBrush}" Stretch="Fill" VerticalAlignment="Center" HorizontalAlignment="Center" RenderTransformOrigin=".5,.5" />
                                                                    </Border>

                                                                    <ControlTemplate.Triggers>
                                                                        <Trigger Property="IsChecked" Value="True">
                                                                            <Setter TargetName="Icon" Property="RenderTransform">
                                                                                <Setter.Value>
                                                                                    <ScaleTransform ScaleY="-1" />
                                                                                </Setter.Value>
                                                                            </Setter>
                                                                        </Trigger>
                                                                        <Trigger Property="IsMouseOver" Value="True">
                                                                            <Setter TargetName="Icon" Property="Fill" Value="{DynamicResource SelectedBrush}" />
                                                                            <Setter TargetName="Border" Property="Background" Value="{DynamicResource MenuHoverBrush}" />
                                                                        </Trigger>
                                                                        <Trigger Property="IsPressed" Value="True">
                                                                            <Setter TargetName="Icon" Property="Fill" Value="{DynamicResource DarkerSelectedBrush}" />
                                                                        </Trigger>
                                                                    </ControlTemplate.Triggers>
                                                                </ControlTemplate>
                                                            </Setter.Value>
                                                        </Setter>
                                                    </Style>
                                                </ToggleButton.Style>
                                            </ToggleButton>


                                            <StackPanel Margin="0,5,0,0" Visibility="{Binding ElementName=PART_AdditionalPropertyOpen, Path=IsChecked, Converter={StaticResource BoolToVis}}">

                                                <!-- Solid brush -->
                                                <DockPanel Margin="0,2">
                                                    <DockPanel.Style>
                                                        <Style TargetType="DockPanel">
                                                            <Setter Property="Visibility" Value="Collapsed" />
                                                            <Style.Triggers>
                                                                <DataTrigger Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}" Value="Solid">
                                                                    <Setter Property="Visibility" Value="Visible" />
                                                                </DataTrigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </DockPanel.Style>

                                                    <TextBlock Text="Opacity" VerticalAlignment="Center" />
                                                    <Slider Style="{StaticResource OpacitySliderStyle}" Margin="10,0,0,0" />
                                                </DockPanel>

                                                <!-- Linear brush -->
                                                <DockPanel>
                                                    <DockPanel.Style>
                                                        <Style TargetType="DockPanel">
                                                            <Setter Property="Visibility" Value="Collapsed" />
                                                            <Style.Triggers>
                                                                <DataTrigger Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}" Value="Linear">
                                                                    <Setter Property="Visibility" Value="Visible" />
                                                                </DataTrigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </DockPanel.Style>

                                                    <UniformGrid Rows="5" DockPanel.Dock="Left" Margin="0,0,5,0">
                                                        <TextBlock Text="Start Point" VerticalAlignment="Center" />
                                                        <TextBlock Text="End Point" VerticalAlignment="Center" />
                                                        <TextBlock Text="Mapping Mode" VerticalAlignment="Center" />
                                                        <TextBlock Text="Spread Method" VerticalAlignment="Center" />
                                                        <TextBlock Text="Opacity" VerticalAlignment="Center" />
                                                    </UniformGrid>

                                                    <UniformGrid Rows="5" DockPanel.Dock="Right">
                                                        <UniformGrid Rows="1">
                                                            <nc:DoubleUpDown Value="{Binding StartX, RelativeSource={RelativeSource TemplatedParent}}" />
                                                            <nc:DoubleUpDown Value="{Binding StartY, RelativeSource={RelativeSource TemplatedParent}}" />
                                                        </UniformGrid>

                                                        <UniformGrid Rows="1">
                                                            <nc:DoubleUpDown Value="{Binding EndX, RelativeSource={RelativeSource TemplatedParent}}" />
                                                            <nc:DoubleUpDown Value="{Binding EndY, RelativeSource={RelativeSource TemplatedParent}}" />
                                                        </UniformGrid>

                                                        <ComboBox Margin="2" ItemsSource="{Binding MappingModeTypes, RelativeSource={RelativeSource TemplatedParent}}" SelectedItem="{Binding MappingMode, RelativeSource={RelativeSource TemplatedParent}}" />

                                                        <ComboBox Margin="2" ItemsSource="{Binding SpreadMethodTypes, RelativeSource={RelativeSource TemplatedParent}}" SelectedItem="{Binding SpreadMethod, RelativeSource={RelativeSource TemplatedParent}}" />

                                                        <Slider Style="{StaticResource OpacitySliderStyle}" />
                                                    </UniformGrid>
                                                </DockPanel>

                                                <!-- Radial brush -->
                                                <DockPanel>
                                                    <DockPanel.Style>
                                                        <Style TargetType="DockPanel">
                                                            <Setter Property="Visibility" Value="Collapsed" />
                                                            <Style.Triggers>
                                                                <DataTrigger Binding="{Binding ElementName=listAvailableBrushType, Path=SelectedValue}" Value="Radial">
                                                                    <Setter Property="Visibility" Value="Visible" />
                                                                </DataTrigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </DockPanel.Style>

                                                    <UniformGrid Rows="7" DockPanel.Dock="Left" Margin="0,0,5,0">
                                                        <TextBlock Text="Gradient Origin" VerticalAlignment="Center" />
                                                        <TextBlock Text="Center" VerticalAlignment="Center" />
                                                        <TextBlock Text="Radius X" VerticalAlignment="Center" />
                                                        <TextBlock Text="Radius Y" VerticalAlignment="Center" />
                                                        <TextBlock Text="Mapping Mode" VerticalAlignment="Center" />
                                                        <TextBlock Text="Spread Method" VerticalAlignment="Center" />
                                                        <TextBlock Text="Opacity" VerticalAlignment="Center" />
                                                    </UniformGrid>

                                                    <UniformGrid Rows="7" DockPanel.Dock="Right">
                                                        <UniformGrid Rows="1">
                                                            <nc:DoubleUpDown Value="{Binding GradientOriginX, RelativeSource={RelativeSource TemplatedParent}}" />
                                                            <nc:DoubleUpDown Value="{Binding GradientOriginY, RelativeSource={RelativeSource TemplatedParent}}" />
                                                        </UniformGrid>

                                                        <UniformGrid Rows="1">
                                                            <nc:DoubleUpDown Value="{Binding CenterX, RelativeSource={RelativeSource TemplatedParent}}" />
                                                            <nc:DoubleUpDown Value="{Binding CenterY, RelativeSource={RelativeSource TemplatedParent}}" />
                                                        </UniformGrid>

                                                        <nc:DoubleUpDown Value="{Binding RadiusX, RelativeSource={RelativeSource TemplatedParent}}" />

                                                        <nc:DoubleUpDown Value="{Binding RadiusY, RelativeSource={RelativeSource TemplatedParent}}" />

                                                        <ComboBox Margin="2" ItemsSource="{Binding MappingModeTypes, RelativeSource={RelativeSource TemplatedParent}}" SelectedItem="{Binding MappingMode, RelativeSource={RelativeSource TemplatedParent}}" />

                                                        <ComboBox Margin="2" ItemsSource="{Binding SpreadMethodTypes, RelativeSource={RelativeSource TemplatedParent}}" SelectedItem="{Binding SpreadMethod, RelativeSource={RelativeSource TemplatedParent}}" />

                                                        <Slider Style="{StaticResource OpacitySliderStyle}" />
                                                    </UniformGrid>
                                                </DockPanel>

                                            </StackPanel>
                                        </StackPanel>
                                    </StackPanel>
                                </Border>
                            </Popup>

                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


</ResourceDictionary>